package com.github.binarylei.hadoop.rpc;

import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC.Builder;
import org.apache.hadoop.ipc.RPC.Server;

import java.io.IOException;

public class RPCServer {

    private static String host = "master";
    private static int port = 10001;

	public static void main(String[] args) throws HadoopIllegalArgumentException, IOException {
        Configuration conf = new Configuration();
        conf.set("fs.defaultFS", "hdfs://master:9000/");
		Builder builder = new Builder(conf);
		
		builder.setBindAddress("master")
                .setPort(port)
				.setProtocol(LoginServiceInterface.class)
				.setInstance(new LoginServiceImpl());
		
		Server server = builder.build();
		
		server.start();
	}
}
